package cn.xinfei.xdecision.prometheus;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.prometheus.PrometheusConfig;
import io.micrometer.prometheus.PrometheusMeterRegistry;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class XMeterRegistryCustomizer {
    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}")String applicationName){
        return (registry)->registry.config().commonTags("applicationName",applicationName);
    }
//
//     @Bean
//     public PrometheusMeterRegistry prometheusMeterRegistry() {
//        log.info("prometheusMeterRegistry init ...");
//        return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
//     }
}
